package mutsumimod.monitors;

import basemod.interfaces.OnPlayerTurnStartSubscriber;
import basemod.interfaces.PostBattleSubscriber;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.CardGroup;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.rooms.AbstractRoom;
import mutsumimod.cards.deprecated.SakiDown;

import java.util.Arrays;

public class SakiDownMonitor extends BaseMonitor implements OnPlayerTurnStartSubscriber, PostBattleSubscriber {

    public static int standReduceThisTurn=0;

    public static void addStandReduceAmount(int amount) {
        standReduceThisTurn+=amount;
        refreshSakiDown();
    }

    @Override
    public void receiveOnPlayerTurnStart() {
        standReduceThisTurn=0;
        refreshSakiDown();
    }

    public static void refreshSakiDown(){
        for(CardGroup group: Arrays.asList(AbstractDungeon.player.hand,AbstractDungeon.player.drawPile,AbstractDungeon.player.discardPile)){
            for(AbstractCard card: group.group){
                if(card instanceof SakiDown){
                    ((SakiDown) card).setCustomVar("SR",SakiDownMonitor.standReduceThisTurn);
                }
            }
        }
    }

    @Override
    public void receivePostBattle(AbstractRoom abstractRoom) {
        standReduceThisTurn=0;
    }
}
